/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.etop.odbs.beans;

import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 *
 * @author cjh
 */
@Entity
@Table(name="download")
public class Download {

    private int id; 
    private Date downloadTime;  //下载时间
    private Document document;  //被下载的文档
    private User user;          //下载文档的用户

    @Id
    @GeneratedValue
    public int getId() {
        return id;
    }

    public Date getDownloadTime() {
        return downloadTime;
    }
    
    @ManyToOne
    @JoinColumn(name="did")
    public Document getDocument() {
        return document;
    }
    
    @ManyToOne
    @JoinColumn(name="uid")
    public User getUser() {
        return user;
    }

    public void setId(int id) {
        this.id = id;
    }

    public void setDownloadTime(Date downloadTime) {
        this.downloadTime = downloadTime;
    }

    public void setDocument(Document document) {
        this.document = document;
    }

    public void setUser(User user) {
        this.user = user;
    }

    @Override
    public String toString() {
        return "Download{" + "id=" + id + ", user=" + user.getNickname() + ", downloadTime=" + downloadTime + ", document=" + document.getFilename() + '}';
    }

}
